package com.hashmap;

import java.util.*;

public class CatHashMap {
    public static void main(String[] args) {
        Car c1 = new Car("奥拓",100);
        Car c2 = new Car("宝马",200);
        Car c3 = new Car("奔驰",300);
        HashMap<Car,Integer> m1 = new HashMap<>();
        m1.put(c1,10000);
        m1.put(c2,500000);
        m1.put(c3,2000000);
        for (Map.Entry<Car, Integer> entry : m1.entrySet()) {
            System.out.println(entry.getKey().getName());
        }
        for (Map.Entry<Car, Integer> entry : m1.entrySet()) {
            if (entry.getKey().getName().equals("宝马")) {
                System.out.println( "宝马的价钱为："+ entry.getValue());
            }
        }

        for (Car car : m1.keySet()) {
            car.setSpeed(car.getSpeed() * 0.8);
            if (car.getName().equals("宝马")) {
                System.out.println(car.getSpeed());
            }
        }






    }
}
